package archer.back.models

import io.circe.{ Decoder, Encoder, ObjectEncoder }
import utils.CirceUtils
import models.CrawlTables._

case class NodeInfoWrap(
  treeNode: UpdateTreeNodeRow,
  info: Option[SimpleNodeInfo],
  isParent: Boolean)

object NodeInfoWrap extends CirceUtils {
  import io.circe.generic.auto._

  implicit val dateEncoder = timestampEncoderFromPattern(
    "yyyy-MM-dd HH:mm:ss.SSS")
  implicit val dateDecoder = timestampDeocderFromPattern(
    "yyyy-MM-dd HH:mm:ss.SSS")

  implicit val NodeInfoWrapObjectEncoder: ObjectEncoder[NodeInfoWrap] = {
    exportEncoder.instance
  }

  implicit val NodeInfoWrapDecoder: Decoder[NodeInfoWrap] = {
    exportDecoder.instance
  }
}
